package com.example.common;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.example.domain.Books;
import com.example.service.BookService;


/*
* 定义一个工具类继承AnalysisEventListener，最重要的是重写invoke方法，去执行excel逻辑
 */
public class ImportListener extends AnalysisEventListener<Books> {
    private BookService bookService;


    @Override
    public void invoke(Books data, AnalysisContext context) {
        bookService.addBook(data);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {

    }

    public ImportListener(BookService userService) {
        this.bookService = bookService;
    }

}

